<%--
XPTracker - Alternative Agile Tracking Tool
Copyright (C) 2006-2009  Stephen Starkey

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
--%>
<%@ include file="/taglibs.jsp" %>
<h3>Categories</h3>
<c:choose>
  <c:when test="${!empty item.categories}">
    <ul>
      <c:forEach items="${xp:groupCategories(item.categories)}" var="entry">
        <li style="background-color:slategray; font-size:0.7em;"><span>${empty entry.key ? 'Default' : entry.key}</span></li>
        <c:forEach items="${entry.value}" var="category">
        <li>
          <ss:secure roles="editor">
            <div class="info-box-float">
              <a href="javascript:removeCategory(${category.id})"><span class="delete-x">x</span></a>
            </div>
          </ss:secure>
            <span>${category.name}</span>
        </li>
        </c:forEach>
      </c:forEach>
    </ul>
  </c:when>
  <c:otherwise>
    <em>No categories found.</em><br/>
  </c:otherwise>
</c:choose>
<ss:secure roles="editor">
<div class="noprint" style="margin-top:5px; font-size:0.8em; text-align:right">
  <select id="availableCategories" name="availableCategories" onchange="addCategory($F('availableCategories'))">
    <option value="">Add...</option>
    <xp:available-categories story="${item}" var="entry">
      <optgroup label="${empty entry.key ? 'Default' : entry.key}">
        <c:forEach items="${entry.value}" var="category">
          <option value="${category.id}">
            ${category.name}
          </option>
        </c:forEach>
      </optgroup>
    </xp:available-categories>
  </select>
</div>
</ss:secure>
